'''
Created on Dec 21, 2011

@author: asakr
'''

import types, itertools

#this is the class variable
class variable(object):
    #to initialize a variable you pass the name as the parameter
    def __init__(self, name):
        self.name = name
    
    #to check whether two variables are equal you pass one referenced to the other example: var1 == var2
    def __eq__(self, other):#returns true if they both have the same name, false otherwise
        if isinstance(other, variable):
            return self.name == other.name
        else:
            return False
        
    def __repr__(self):#returns the name if its being printed
        return self.name

    def __iter__(self):#returns the iter([]) 
        return iter([])

#the constant class -----> Same explanation as that for variable class but for constant
class constant(object):
    def __init__(self, content):
        self.content = content
        
    def __eq__(self, other):
        if isinstance(other, constant):
            return self.content == other.content
        else:
            return False
        
    def __iter__(self):
        return iter([])
    
    def __repr__(self):
        return self.content

#the function class -----> Same explanation as that for variable class but for function
class function(object):
    def __init__(self, name):
        self.name = name
        
    def __eq__(self, other):
        if isinstance(other, function):
            return self.name == other.name
        else:
            return False
    
    def __repr__(self):
        return self.name
    
    def __iter__(self):
        return iter([])

#the predicate class -----> Same explanation as that for variable class but for predicate
class predicate(object):
    def __init__(self, name):
        self.name = name
        
    def __eq__(self, other):
        if isinstance(other, predicate):
            return self.name == other.name
        else:
            return False
    
    def __repr__(self):
        return self.name
    
    def __iter__(self):
        return iter([])

class strip(object):
    def __init__(self, precondition, action, effect):
        self.precondition = precondition #list in CNF - conjunction of +ve literals
        self.action = action 
        self.effect = effect #list in CNF - conjunction of literals
        
    def __repr__(self):
        s = ''
        s = s+'Precondition: { '
        for i in self.precondition:
            s=s+i+' '
        s = s+'}'
        if not self.action == None:
            s = s+' Action: {'+self.action+'}'
        else:
            s=s+'Action: {}'
        s = s+'Effect: { '
        for i in self.effect:
            s=s+i+' '
        s = s+'}'
        return s
    
def POP(initial, goal, strips):
    plan = []
    return plan

def linearize(plan):
    return plan

if __name__ == '__main__':
    pass